home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
wics.zip
/
DEMOWIN.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-19
|
7KB
|
232 lines
//==============================================================================================
//
// WICS Demonstration Application
// Version 1.00
//
// DEMO.CPP main application code file
// February 1993
//
// Copyright (C) 1993 Microdyne Development Technologies
//
//==============================================================================================
//
// Abstract:
//
//
//==============================================================================================
#include <owl.h>
#include <wics.h>
#include <demorc.h>
#include <demo.h>
#include <eframe.h>
#include <filewnd.h>
#include <dedtwin.h>
#include <smpldlg.h>
//----------------------------------------------------------------------------------------------
// Constructor for TDemoWindow
//
// The TDemoWindow is the main frame window of the Line Information Database application. This
// window contains all user work areas as child windows. The routine creates a speed bar (or
// Icon Bar) control, sets the child window list to item 1 of the default menu (this is the
// Window item) and records the active menu as the default menu for the application. The
// default menu for the application contains only three items, File, Window and Help. Once the
// application window is created, the Window item is removed from the main menu.
//----------------------------------------------------------------------------------------------
TDemoWindow::TDemoWindow(LPSTR ATitle, int Menu) :
TExtendedMDIFrame(ATitle, Menu, TRUE, TRUE)
{
ChildMenuPos = 3;
}
//-------------------------------------------------------------------------------------
// Destructor for TDemoWindow
//
// The destructor is called when the application terminates. All child windows are
// destroyed automatically.
//-------------------------------------------------------------------------------------
TDemoWindow::~TDemoWindow()
{
}
//-------------------------------------------------------------------------------------
// SetupWindow
//
// This routine calls the default windows setup procedure for frame windows
// (TExtendedMDIFrame::SetupWindow). Then, the routine locates and records the menu
// item handle for the Window entry in the main menu. The Window entry is then removed
// from the main menu.
//
// Note: The Window entry is not destroyed, it merely remains in memory to be added
// to the menu again at a later time. The Window entry holds the list of
// active child windows.
//-------------------------------------------------------------------------------------
void TDemoWindow::SetupWindow ()
{
int rcd ;
TExtendedMDIFrame::SetupWindow();
GetStatusBar()->AppendArea(80, "Ready", 0x000080);
SetIconBarStartPoint(4);
PlaceIconBarButton (IBID_FILEOPEN);
PlaceIconBarButton (IBID_FILESAVE);
InsertIconBarSpace();
PlaceFontSelectionControl(ID_FONTSELECT);
InsertIconBarSpace();
PlaceIconBarButton (IBID_UNDO);
PlaceIconBarButton (IBID_CUT);
PlaceIconBarButton (IBID_COPY);
PlaceIconBarButton (IBID_PASTE);
InsertIconBarSpace();
PlaceIconBarButton (IBID_BOLD, TRUE);
PlaceIconBarButton (IBID_ITALIC, TRUE);
InsertIconBarSpace();
PlaceIconBarButton (IBID_PRINTER);
SetIconBarButtonCommandCode (IBID_FILEOPEN, CM_OPEN);
SetIconBarButtonCommandCode (IBID_FILESAVE, CM_FILESAVE);
SetIconBarButtonCommandCode (IBID_CUT, CM_EDITCUT);
SetIconBarButtonCommandCode (IBID_COPY, CM_EDITCOPY);
SetIconBarButtonCommandCode (IBID_PASTE, CM_EDITPASTE);
SetIconBarButtonCommandCode (IBID_UNDO, CM_EDITUNDO);
SetIconBarButtonCommandCode (IBID_BOLD, CM_BOLD);
SetIconBarButtonCommandCode (IBID_ITALIC, CM_ITALIC);
SetIconBarButtonCommandCode (IBID_PRINTER, CM_PRINT);
SetFontFamilyCommandCode (CM_FONTCHANGED);
SetFontSizeCommandCode (CM_FONTSIZECHANGED);
SetIconBarButtonState (IBID_LEFT, TRUE);
SetIconBarButtonState (IBID_CENTER, FALSE);
SetIconBarButtonState (IBID_RIGHT, FALSE);
SetIconBarButtonState (IBID_DECIMAL, FALSE);
}
//-------------------------------------------------------------------------------------
// GetWindowClass
//
// This routine retreives the default values for the window class. Then, the routine
// adds the LIDB_ICON to the class.
//-------------------------------------------------------------------------------------
void TDemoWindow::GetWindowClass(WNDCLASS& WndClass)
{
TExtendedMDIFrame::GetWindowClass( WndClass );
WndClass.hIcon = LoadIcon( GetApplication()->hInstance, MAKEINTRESOURCE(DEMO_ICON));
}
void TDemoWindow::DefWndProc (RTMessage Msg)
{
if ( Msg.Message == ((PTDemoApp)GetApplication())->idHelpMessage )
WMCommDlgHelp (Msg);
else
TExtendedMDIFrame::DefWndProc(Msg);
}
void TDemoWindow::WMCommDlgHelp (RTMessage)
{
}
void TDemoWindow::CMHelpIndex (RTMessage)
{
LPSTR lpHelpFile = new char[128];
lstrcpy ( lpHelpFile, "DEMO.HLP");
WinHelp (HWindow, lpHelpFile, HELP_CONTENTS, 0L);
delete lpHelpFile;
}
void TDemoWindow::CMUsingHelp (RTMessage)
{
LPSTR lpHelpFile = new char[128];
lstrcpy ( lpHelpFile, "DEMO.HLP");
WinHelp (HWindow, lpHelpFile, HELP_HELPONHELP, 0L);
delete lpHelpFile;
}
void TDemoWindow::CMAbout (RTMessage)
{
}
void TDemoWindow::CMSampleDialog (RTMessage)
{
GetModule()->ExecDialog( new TSampleDialog(this));
}
void TDemoWindow::CMChooseColor (RTMessage)
{
CHOOSECOLOR cc;
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = HWindow;
cc.hInstance = GetApplication()->hInstance;
cc.rgbResult = RGB(0,0,0);
cc.lpCustColors = rgbCustom;
cc.Flags = CC_FULLOPEN | CC_SHOWHELP;
ChooseColor (&cc);
}
void TDemoWindow::CMOpen (RTMessage)
{
int i;
LPSTR lpFilter;
OPENFILENAME ofn;
lpFilter = new char [80];
lstrcpy (lpFilter, "All Files?*.*?ASCII Files?*.CSV?") ;
for ( i = lstrlen(lpFilter) ; i > 0 ; i-- )
if ( *(lpFilter+i) == '?' )
*(lpFilter+i) = 0 ;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = HWindow;
ofn.hInstance = GetApplication()->hInstance;
ofn.lpstrFilter = lpFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = new char[128];
ofn.nMaxFile = 128;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = "C:\\";
ofn.lpstrTitle = "Open File";
ofn.Flags = OFN_PATHMUSTEXIST | OFN_SHOWHELP | OFN_FILEMUSTEXIST ;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = "DAT";
ofn.lCustData = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
lstrcpy (ofn.lpstrFile, "");
if ( GetOpenFileName (&ofn))
{
GetApplication()->MakeWindow (new TDemoEditWindow(this, ofn.lpstrFileTitle, ofn.lpstrFile));
}
delete lpFilter;
}
void TDemoWindow::CMNew (RTMessage)
{
GetApplication()->MakeWindow (new TDemoEditWindow(this, NULL, NULL));
}